﻿using DoNetDrive.Common.Extensions;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _8280WEBSocket.Command.Record
{
    public class GetRecordResult : Json.JsonCommandResult
    {
        Record_DTO JsonResultValue;
        public GetRecordResult(Models.RecordType type, string values) : base(values)
        {
            JsonResultValue = values.FromJson<Record_DTO>();
            var records = JsonResultValue.Records.ToString();
            if (type == Models.RecordType.Alarm)
            {
                JsonResultValue.Records = records.FromJson<List<Models.AlarmRecord>>();
            }
            else if (type == Models.RecordType.Enter)
            {
                JsonResultValue.Records = records.FromJson<List<Models.CardRecord>>();
            }
            else if (type == Models.RecordType.System)
            {
                JsonResultValue.Records = records.FromJson<List<Models.SystemRecord>>();
            }
            else
            {
                JsonResultValue.Records = records.FromJson<List<Models.DoorSensorRecord>>();
            }
        }


    }
}
